<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>添加导航页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../static/css/font.css">
		<link rel="stylesheet" href="../../../static/css/weadmin.css">
  </head>
  
  <body>
    <div class="weadmin-body">
        <form class="layui-form" action="/admin/nav/add" method="post">
          <div class="layui-form-item">
              <label for="" class="layui-form-label">
                  <span class="we-red">*</span>导航
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="navName" name="navName" value="" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="we-red">*</span>状态
            </label>
            <div class="layui-input-inline">
                <input type="checkbox" checked="" name="state" lay-skin="switch" lay-filter="switchTest" lay-text="启用|禁用">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="we-red">*</span>默认启用状态
            </div>
        </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="add">
                  添加
              </button>
          </div>
      </form>
    </div>
    <script src="../../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript">
    	layui.extend({
				admin: '{/}../../../static/js/admin'
			});
	    layui.use(['form','layer','admin','jquery','transfer'], function(){
	      var form = layui.form,
	      admin = layui.admin,
	      layer = layui.layer;
        var $ = layui.jquery;

          //监听提交
          form.on('submit(add)', function(data){
            console.log(data);
            $.ajax({
              url:"/admin/nav/add",
              method:"post",
              data:data.field
            }).then(function(res){ //提交后
            //     layer.msg('同上', {
            //    icon: 1,
            //   time: 2000 //2秒关闭（如果不配置，默认是3秒）
            // },
              //发异步，把数据提交给nodejs
            layer.alert("添加成功", {icon: 6},function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
                //添加成功后刷新页面
                parent.location.reload();
            });
            })
            return false;
          });
        });
    </script>
  </body>

</html>